<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<div class="bjui-pageContent" style="top: 0; bottom: 35px;">
    <span style="text-align: center"><h4>用户详情</h4></span>
    <ul class="nav nav-tabs" role="tablist">
        <li class="active">
            <a href="#home_${user.id}" role="tab" data-toggle="tab">基本信息</a>
        </li>
        <li class="">
            <a href="#home2_${user.id}" role="tab" data-toggle="tab">资金信息</a>
        </li>
        <li>
            <a href="#buy_${user.id}" role="tab" data-toggle="tab" onclick="repayListCallback_${user.id}(1, 10)">投资</a>
        </li>
        <li>
            <a href="#loan_${user.id}" role="tab" data-toggle="tab">借款</a>
        </li>
        <li>
            <a href="javascript:userJournalNavTab(${user.userName});">用户流水</a>
        </li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content">
        <div class="tab-pane fade active in" id="home_${user.id}">
            <div data-layout-h="0" class="bjui-row col-2">
                <label class="row-label">用户名:</label>
                <div class="row-input">
                    ${user.userName}
                </div>

                <label class="row-label">emali:</label>
                <div class="row-input">
                    ${user.emali}
                </div>

                <label class="row-label">手机号:</label>
                <div class="row-input">
                    ${user.phone}
                </div>

                <label class="row-label">真实姓名:</label>
                <div class="row-input">
                    ${user.name}
                </div>

                <label class="row-label">身份证号码:</label>
                <div class="row-input">
                    ${user.idNumber}
                </div>

                <label class="row-label">性别:</label>
                <div class="row-input">
                    ${user.sex == null ? '' : (user.sex == 1 ? '男' : '女')}
                </div>

                <label class="row-label">用户类型:</label>
                <div class="row-input">
                    ${user.userType}
                </div>

                <label class="row-label">投资顾问:</label>
                <div class="row-input">
                    ${user.salemanName}
                </div>
                <label class="row-label">用户状态:</label>
                <div class="row-input">
                    <c:choose>
                        <c:when test="${user.status == 0}">正常</c:when>
                        <c:when test="${user.status == 1}">已注销</c:when>
                        <c:when test="${user.status == 2}">已禁用</c:when>
                        <c:otherwise>
                            ${user.status}
                        </c:otherwise>
                    </c:choose>
                </div>
                <label class="row-label">投资顾问手机:</label>
                <div class="row-input">
                ${user.salemanPhone}
                </div>


                <label class="row-label">是否授权:</label>
                <div class="row-input">
                    <c:choose>
                        <c:when test="${user.authorize}">是</c:when>
                        <c:otherwise>
                            否
                        </c:otherwise>
                    </c:choose>
                </div>

                <label class="row-label">是否认证/开户:</label>
                <div class="row-input">
                    <c:choose>
                        <c:when test="${user.openAccount}">是</c:when>
                        <c:otherwise>
                            否
                        </c:otherwise>
                    </c:choose>
                </div>

                <label class="row-label">第三方支付平台标识:</label>
                <div class="row-input">
                    ${user.accountModel.payPlatformID}
                </div>

                <label class="row-label">注册时间:</label>
                <div class="row-input">
                    <fmt:formatDate value="${user.lastLoginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </div>

                <label class="row-label">第三方支付平台数字标识:</label>
                <div class="row-input">
                    ${user.accountModel.payPlatformNumber}
                </div>

                <label class="row-label">最后登录:</label>
                <div class="row-input">
                    <fmt:formatDate value="${user.registerDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </div>

            </div>
        </div>
        <div class="tab-pane fade" id="home2_${user.id}">
            <div data-layout-h="0" class="bjui-row col-2">

                <label class="row-label"><b>资金信息:</b></label>
                <div class="row-input">&nbsp;</div>
                <label class="row-label">&nbsp;</label>
                <div class="row-input">&nbsp;</div>
                <label class="row-label">总资金:</label>
                <div class="row-input">
                    ${user.accountModel.totalProperty}
                </div>
                <label class="row-label">累计收益:</label>
                <div class="row-input">
                    ${user.accountModel.profit}
                </div>
                <label class="row-label">冻结金额:</label>
                <div class="row-input">
                    ${user.accountModel.freezing}
                </div>
                <label class="row-label">可用余额:</label>
                <div class="row-input">
                    ${user.accountModel.balance}
                </div>
                <hr>
                <div data-layout-h="0" class="bjui-row col-2">
                    <label class="row-label"><b>投资信息:</b></label>
                    <div class="row-input">&nbsp;</div>
                    <label class="row-label">&nbsp;</label>
                    <div class="row-input">&nbsp;</div>

                    <label class="row-label">已投金额:</label>
                    <div class="row-input">
                        ${user.accountModel.assets}
                    </div>
                    <label class="row-label">代收本金:</label>
                    <div class="row-input">
                        ${user.accountModel.assets}
                    </div>
                    <label class="row-label">投资笔数:</label>
                    <div class="row-input">
                        ${countRepay}
                    </div>
                    <label class="row-label">预收益:</label>
                    <div class="row-input">
                        ${user.accountModel.collect}
                    </div>
                </div>
                <hr>
                <div data-layout-h="0" class="bjui-row col-2">
                    <label class="row-label"><b>借款信息:</b></label>
                    <div class="row-input">&nbsp;</div>
                    <label class="row-label">&nbsp;</label>
                    <div class="row-input">&nbsp;</div>

                    <label class="row-label">借款金额:</label>
                    <div class="row-input">
                        ${loanAmount}
                    </div>
                    <label class="row-label">应还本金:</label>
                    <div class="row-input">
                        ${repayMoney}
                    </div>
                    <label class="row-label">借款笔数:</label>
                    <div class="row-input">
                        ${countLoan}
                    </div>
                    <label class="row-label">应付利息:</label>
                    <div class="row-input">
                        ${interestD}
                    </div>
                    <label class="row-label">还款时间:</label>
                    <div class="row-input">
                        <fmt:formatDate value="${date}" pattern="yyyy-MM-dd"/>
                    </div>
                    <label class="row-label">逾期罚金:</label>
                    <div class="row-input">
                        ${overD}
                    </div>
                </div>
            </div>
        </div>
        <!-- buy -->
        <div class="tab-pane fade" id="buy_${user.id}">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <td align="center">标名</td>
                    <td align="center">标号</td>
                    <td align="center">投资金额</td>
                    <td align="center">实际收益</td>
                    <td align="center">投资时间</td>
                    <td align="center">标的状态</td>
                </tr>
                </thead>
                <tbody id="tbody_${user.id}">
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="6">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2">合计:</td>
                    <td id="totalBuyMoney_${user.id}" align="center">0.00</td>
                    <td id="totalCollect_${user.id}" align="center">0.00</td>
                    <td colspan="2"></td>
                </tr>
                </tfoot>
            </table>
            <div data-toggle="pagination"
                 data-options="{selectPageSize:'10,20,30',total:${countRepay},pageSize:10, callback:repayListCallback_${user.id}}"></div>
        </div>

        <!-- loan -->
        <div class="tab-pane fade" id="loan_${user.id}">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <td align="center">标名</td>
                    <td align="center">标号</td>
                    <td align="center">借款金额</td>
                    <td align="center">标的状态</td>
                    <td align="center">借款时间</td>
                    <td align="center">还款详情</td>
                </tr>
                </thead>
                <tbody>
                <c:set var="totalLoanAmount" value="0"/>
                <c:forEach items="${loan.list}" var="l">
                    <tr>
                        <td align="center">
                                ${l.fullName}
                        </td>
                        <td align="center">
                            <a href="javascript:userInfoloanInfo(${l.loanId})">${l.loanNumber}</a>
                        </td>
                        <td align="center">
                                ${l.loanAmountD}
                        </td>
                        <td align="center">
                                ${l.loanStatusStr}
                        </td>
                        <td align="center">
                            <fmt:formatDate value="${l.addDate}" pattern="yyyy-MM-dd"/>
                        </td>
                        <td align="center">
                            <a href="javascript:userInfoloanInfo(${l.loanId})">查看</a>
                        </td>
                    </tr>
                    <c:set value="${totalLoanAmount + l.loanAmountD}" var="totalLoanAmount"/>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="6">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2">合计:</td>
                    <td align="center"><fmt:formatNumber value="${totalLoanAmount}" pattern="####0.00"/></td>
                    <td colspan="3"></td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<!-- close -->
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn btn-close" data-icon="close"><i class="fa fa-close"></i> 关闭</button>
        </li>
    </ul>
</div>
<script type="text/javascript">
    function userInfoloanInfo(loanId) {
        BJUI.dialog({
            id: 'loanInfo' + loanId,
            url: '/admin/loan/loan/info?loanId=' + loanId,
            title: loanId + '标的详情',
            width: 1200,
            height: 1200 * 0.618
        })
    }

    function userJournalNavTab(name) {
        navTab("userJournal", "userJournal?userName=" + name, "用户流水");
    }

    function navTab(id, url, title) {
        $('.minimize').click();
        BJUI.navtab({
            id: id,
            url: "/admin/capital/" + url,
            title: title
        })
    }

    function repayListCallback_${user.id}(pageCurrent, pageSize) {
        BJUI.ajax('doajax', {
            url: '/admin/capital/loanAjax?userId=' + ${user.id},
            data: {pageCurrent: pageCurrent, pageSize: pageSize},
            dataType: 'json',
            okCallback: function (json) {
                if (json) {
                    var trs = BJUI.StrBuilder();
                    $.each(json.repayList, function (i, n) {
                        trs.add('<tr><td align="center">')
                            .add(n.loanName).add('</td><td align="center">')
                            .add('<a href="javascript:userInfoloanInfo(' + n.loanId + ')">' + n.loanNumber + '</a>').add('</td><td align="center">')
                            .add(n.buyMoney).add('</td><td align="center">')
                            .add(n.collect).add('</td><td align="center">')
                            .add(n.buyDate.substr(0,19)).add('</td><td align="center">')
                            .add(n.loanStatus).add('</td></tr>')
                    });
                    $('#tbody_${user.id}').html(trs.toString());

                    $('#totalCollect_${user.id}').html(json.totalCollect);
                    $('#totalBuyMoney_${user.id}').html(json.totalBuyMoney);
                }
            },
            errCallback: function (json) {
                alert('请求失败！' + json);
            }
        })
    }
</script>